import { Server } from "socket.io";

const io = new Server({path: '/socket.io'});

io.serveClient(false);

io.on('connection', (sock) => {
    console.log('connection');

    sock.on('disconnect', () => {
        console.log('disconnect');
    });

    sock.on('join_room', function({room}) {
        sock.join(room);
    });
    sock.on('leave_room', function({room}) {
        sock.leave(room);
    });

    sock.on('message', function({room, message}) {
        io.to(room).emit('message', message);
    });
    
})




io.listen(3000);